import React, { useEffect, useState } from "react";
import { Space, Table, Tag } from "antd";
import axios from "../../api/request";
import { Pagination } from "antd";
import Headers from "../../components/Headers";
function List() {
  const [data, setData] = useState([]);

  //
  const [zts, setZts] = useState(0);
  // 当前页数
  const [current, setCurrent] = useState(1);
  // 每页多少条
  const [pageSize, setPageSize] = useState(6);

  const onChange = (page, pageSize) => {
    setCurrent(page);
    setPageSize(pageSize);
  };
  const onShowSizeChange = (current, size) => {
    setCurrent(current);
    setPageSize(size);
  };

  const getdata = () => {
    axios
      .get("/article/list", {
        params: {
          page: current,
          pageSize: pageSize,
          keyword:null,
          tag:null

        },
      })
      .then((res) => {
        console.log(res);
        setData(res.data.rows);
      });
  };
  useEffect(() => {
    getdata();
  }, [current,pageSize]);
  const columns = [
    {
      title: "content",
      dataIndex: "content",
      key: "content",
      render: (text) => <a>{text}</a>,
    },
    {
      title: "title",
      dataIndex: "title",
      key: "title",
    },
    {
      title: "createdAt",
      dataIndex: "createdAt",
      key: "createdAt",
    },
    {
      title: "Action",
      key: "action",
      render: (_, record) => (
        <Space size="middle">
          <a>Invite {record.name}</a>
          <a>Delete</a>
        </Space>
      ),
    },
  ];
  return (
    <div>
      <Headers></Headers>
      <Table columns={columns} dataSource={data} pagination={false} />
      <Pagination
        total={85}
        current={current}
        pageSize={pageSize}
        onChange={onChange}
        onShowSizeChange={onShowSizeChange}
        // showTotal={(total) => `Total ${total} items`}
      />
    </div>
  );
}

export default List;
